import os
import sys

from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QTranslator
from loguru import logger

from business.main_ui import MainWindow
from utils import utils

__dir__ = os.path.dirname(__file__)

if __name__ == '__main__':
    import cgitb

    cgitb.enable(format='text')
    bin_path = os.path.abspath(os.path.join(__dir__, '../bin/'))
    utils.add_env_path(bin_path)
    log_path = os.path.abspath(os.path.join(__dir__, '../output/', 'tts.log'))
    logger.add(log_path, rotation="1024KB")
    app = QApplication(sys.argv)
    trans = QTranslator()
    trans.load("zh_CH")
    app.installTranslator(trans)
    window = MainWindow()
    window.show()
    sys.exit(app.exec())
